package com.monkey.luffer.springboot.demo.basis.kcc.utils;

import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * @author jiahong.liu
 */
public class ShellUtil {
    public static String runShell (String shStr) throws Exception {

        Process process;
        process = Runtime.getRuntime().exec( new String[]{ "/bin/sh" , "-c" ,shStr});
        process.waitFor();
        BufferedReader read = new BufferedReader( new InputStreamReader(process.getInputStream()));
        String line = null ;
        StringBuilder result = new StringBuilder();
        while ((line = read.readLine())!= null ){
            result.append(line);
        }
        return result.toString();
    }

}
